package com.reebake.ideal.storage.controller.client;

import com.reebake.ideal.storage.client.FileOperationClient;
import com.reebake.ideal.storage.entity.FileInfoDTO;
import com.reebake.ideal.storage.entity.FileListViewDTO;
import com.reebake.ideal.storage.service.FileOperationService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequiredArgsConstructor
@RequestMapping("/client/storage/file")
public class FileOperationClientController implements FileOperationClient {
    private final FileOperationService fileOperationService;

    @Override
    public FileInfoDTO fileInfo(String url) {
        return fileOperationService.fileInfo(url);
    }

    @Override
    public FileInfoDTO fileInfo(@RequestParam(required = false) String platform, String path, String filename) {
        return fileOperationService.fileInfo(platform, path, filename);
    }

    @Override
    public Boolean exists(String url) {
        return fileOperationService.exists(url);
    }

    @Override
    public Boolean exists(@RequestParam(required = false) String platform, String path, String filename) {
        return fileOperationService.exists(platform, path, filename);
    }

    @Override
    public void delete(String url) {
        fileOperationService.delete(url);
    }

    @Override
    public void delete(@RequestParam(required = false) String platform, String path, String filename) {
        fileOperationService.delete(platform, path, filename);
    }

    @Override
    public FileInfoDTO copy(String url, @RequestParam(required = false) String platform, String path) {
        return fileOperationService.copy(url, platform, path);
    }

    @Override
    public FileInfoDTO move(String url, @RequestParam(required = false) String platform, String path) {
        return fileOperationService.move(url, platform, path);
    }

    @Override
    public FileListViewDTO list(@RequestParam(required = false) String platform, String path, @RequestParam(required = false) String marker, @RequestParam(required = false) Integer maxFiles) {
        return fileOperationService.list(platform, path, marker, maxFiles);
    }

}
